package org.wsalger.serviceimpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wsalger.dao.UserMapper;
import org.wsalger.dao.ZMZSysBaseMapper;
import org.wsalger.model.User;
import org.wsalger.service.UserServiceI;
import org.wsalger.tools.ClsTools;

@Service("userService")
public class UserServiceImpl implements UserServiceI {
	private UserMapper userMapper;
	private ZMZSysBaseMapper zmzSysBaseMapper;
	public UserMapper getUserMapper() {
		return userMapper;
	}
	@Autowired
	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}
	public ZMZSysBaseMapper getZmzSysBaseMapper() {
		return zmzSysBaseMapper;
	}
	@Autowired
	public void setZmzSysBaseMapper(ZMZSysBaseMapper zmzSysBaseMapper) {
		this.zmzSysBaseMapper = zmzSysBaseMapper;
	}

	@Override
	public String getSystemDate() {
		// TODO Auto-generated method stub
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return zmzSysBaseMapper.getSystemDate()+"|"+df.format(new Date());
	}
	@Override
	public String getUser(String username, String userpass) {
		// TODO Auto-generated method stub
		Map u=userMapper.g_selectByNameAndPass(ClsTools.MD5(username),ClsTools.MD5(userpass));
		return u.get("id").toString()+"|"+u.get("chinesename")+"|"+u.get("rolecontext");
	}	
}
